Xbasic

BYTES_TO_MEGA Function

Syntax

Formatted_Count as C = bytes_to_mega(N bytes [,N decimal_places ])

Arguments

bytes

The count of bytes to reformat. Numeric

decimal_places

Optional. The number of decimal places to display. Numeric

Description

Convert bytes to KB, MB, GB, TB...

Discussion

The BYTES_TO_MEGA() function returns the KB, MB, GB, or TB equivalent of a byte number.

Example

? bytes_to_mega(65536)
= "64 KB"
? bytes_to_mega(9023482)
= "8.6 MB"
? bytes_to_mega(9023482, 4)
= "8.6055 MB"
? bytes_to_mega(390482509348, 2)
= "363.67 GB"

See Also